package com.mall.malladminbackend.model;

import lombok.Builder;
import lombok.Data;

// 返回结果
@Data
@Builder
public class R {
    private Integer code;
    private String msg;
    private Object data;

    public static R buildFailure() {
        return buildFailure("failure");
    }

    public static R buildFailure(String msg) {
        return buildFailure(-1, msg);
    }

    public static R buildFailure(Integer code, String msg) {
        return R.builder().code(code).msg(msg).build();
    }

    public static R buildSuccess(Integer code, String msg, Object data) {
        return R.builder().code(code).msg(msg).data(data).build();
    }

    public static R buildSuccess(Object data) {
        return buildSuccess(1, "success", data);
    }

    public static R buildSuccess(Integer code, String msg) {
        return buildSuccess(code, msg, null);
    }

    public static R buildSuccess(Integer code) {
        return buildSuccess(code, "success", null);
    }

    public static R buildSuccess() {
        return buildSuccess(1);
    }
}
